<include file="Public/header" /> 

<!--主窗体-->
<div class="container app">
	<!--左侧菜单-->
	<include file="Public/sidebar" /> 
	<!--左侧菜单//-->
	
	<!-- mainCon -->
	<div id="mainCon" class="mainCon">
		<h4>
			添加角色
		</h4>
		<form class="form-horizontal" id="myform">
			<div class="form-group">
				<label for="name" class="col-sm-2 control-label">角色名称</label>
				<div class="col-sm-5">
					<input type="text" name="name" class="form-control" id="name" placeholder="角色名称">
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">状态</label>
				<div class="radio col-sm-5">
					<label>
						<input type="radio" name="status" id="role2" value="1" checked>
					   	启用
					</label>
					<label>
						<input type="radio" name="status" id="role1" value="0">
					   	禁用
					</label>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-default col-sm-2">保存</button>
				</div>
			</div>
		</form>
		
	</div>
	<!-- mainCon// -->
	
</div>
<!--主窗体//-->

<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/validate/messages_zh.js"></script>
<script>
$(function(){
	
	$("#myform").validate({
		rules: {
			name : {
				required: true,
			},
		},
		messages: {
		
		},
		submitHandler : function(form){
			var ajaxUrl = "<{:U('Admin/Role/do_add')}>";
			 $.post(ajaxUrl,$(form).serialize(),function(r){
    			if (r.error == 1){
    				layer.alert(r.errmsg,{icon: 2});
    			}else{
    				layer.alert(r.errmsg,{icon: 1},function(){
    					window.location.href = "<{:U('Admin/Role/lists',array('k'=>5,'sk'=>5))}>";
    				});
    			}
    			return false;
    		});
        	return false
		}
	});
});
</script>

<include file="Public/footer" /> 